<?php
/**
 * Created by PhpStorm.
 * User: SUNHUATAO
 * Desc: 留言管理控制器
 */
namespace App\Modules\Manage\Http\Controllers;
use App\Http\Controllers\ManageController;
use Illuminate\Http\Request;
use App\Modules\Manage\Model\MessageModel;
class MessageController extends ManageController
{
    public function __construct()
    {
        parent::__construct();
        $this->initTheme('manage');
        $this->theme->set('manageType', 'auth');

    }

    /**
     * 列表展示
     */
    public function messageList(Request $request)
    {
        $merge = $request->all();
        $list = MessageModel::select('*')->orderBy('create_time','desc')->paginate(8);

        $listArr = $list->toArray()['data'];
        $data = array(
            'merge' => $merge,
            'listArr' => $listArr,
            'list' => $list
        );
        return $this->theme->scope('manage.messageList',$data)->render();
    }
    public function messageDelete($id)
    {
        $res = MessageModel::where('id', $id)->delete();
        if($res)
        {
            return redirect()->to('manage/message')->with(['message'=> '删除成功!']);
        }else{
            return redirect()->back()->with(['error'=> '删除失败,请重试!']);
        }

    }

}